#pragma once
#include <string>
#include <map>
using std::string;
using std::map;
using std::pair;
class Val
{
public:
    enum { VAL, NUMBER }type;
    int ptr;
};
struct ValLog
{
    unsigned length;
    int offset;
    bool editable;
};

class ValMgr {
public:
    typedef enum { GLOBAL, FUNCTION, BLOCK }VMTYPE;
private:
    VMTYPE _mode;
    ValMgr* _father_block;
    int _offset;
    int _reserve;
    map<string, ValLog>_val_logs;
public:
    ValMgr(VMTYPE mode, ValMgr* father_block);
    ValMgr* GetFatherBlockValMgr();
    bool Alloc(string str, bool editable);
    void Update(int n);
    bool Lookup(string str);
    ValLog QueryVal(string str);
    int QueryOffset(string str);
    int QueryOffsetRegister(string str);
    bool QueryEditability(string str);
    //TODO add feature
};
